Ext.define('UmlWebEditor.tests.StoreTest', {
	extend: 'UmlWebEditor.tests.Test',
	requires: [
		'UmlWebEditor.factories.DiagrammFactory'
	],
	tests: {
		removeAllDiagrammsTest: function () {
			var controller = Ext.UmlWebEditor.getController('WorkSpaceController');
			var commonDiagrammController = Ext.UmlWebEditor.getController('CommonDiagrammController');
			var workSpaceWidget = Ext.create('UmlWebEditor.view.WorkSpace', {
				renderTo: Ext.getBody()
			});
			var store = workSpaceWidget.getDiagrammStore();

			var oldCount = store.count();
			controller.onCreateDiagramm('CommonDiagramm');
			verify(oldCount + 1 == store.count(), "store count not increment");

			//store.removeAll();
			for(var i = 0; i< store.count();)
				store.removeAt(i);
			verify(0 == store.count(), "store not cleaned");

			store.sync();
			verify(0 == store.count(), "sync store not cleaned");

			/*commonDiagrammController.addBlock({
				x: 0,
				y: 0,
				type: 'SimpleBlock'
			});

			verify(error, "createBlock - not catch error");*/

			workSpaceWidget.destroy();

			var workSpaceWidget = Ext.create('UmlWebEditor.view.WorkSpace', {
				renderTo: Ext.getBody()
			});
			var store = workSpaceWidget.getDiagrammStore();
			verify(1 == store.count(), "store not cleaned after recreated");

			workSpaceWidget.destroy();
		},
		idCreatedDiagrammTest: function () {
			var controller = Ext.UmlWebEditor.getController('WorkSpaceController');
			var workSpaceWidget = Ext.create('UmlWebEditor.view.WorkSpace', {
				renderTo: Ext.getBody()
			});
			var store = workSpaceWidget.getDiagrammStore();

			for(var i = 0; i< store.count();)
				store.removeAt(i);

			store.sync();

			controller.onCreateDiagramm('CommonDiagramm');
			controller.onCreateDiagramm('CommonDiagramm');

			store.each(function(item) {
				verify(item.id = -1, "id of new diagramm > -1");
			});

			workSpaceWidget.destroy();
		},
	}
});
